$('#readMessage').text('初始化中...');
Require('./api/Menu.js');  //动态导航
window.proxy = Require('./proxy/proxy.js')();
window.__DBConfig__ = {};
window.__CacheData__ = {};
window.__DBObject__ = null;
window.__CacheValue__ = {};
// var __DBObjectReady__ = [false, false, false];
// var checkReady = function () {
//     setTimeout(function () {
//         var isReady = true;
//         for (let i = 0; i < __DBObjectReady__.length; i++) {
//             const element = __DBObjectReady__[i];
//             if (!element) {
//                 isReady = false;
//                 break;
//             }
//         };
//         if (isReady) {
//             renderFiles();
//         } else {
//             checkReady();
//         };
//     }, 1000);
// };
var renderFiles = function () {
    $('#readMessage').text('渲染页面...');
    Require('./api/render.js');
};
proxy.getId((error, id) => {
    if (error || id === null) {
        createWindow();
        return;
    } else {
        $('#readMessage').text('读取用户配置文件...');
        proxy.getPorjectConfig(id, (data) => {
            __DBConfig__ = data;
            $('#readMessage').text('读取保存记录...');
            $('title').text('Requester - ' + data.title);
            proxy.getPorjectLastControl(id, (error, data) => {
                if (error) {
                    __CacheData__ = {
                        "listArray": [],
                        "listActiveObjId": null,
                        "tabArray": [],
                        "tabActiveObjId": null,
                        "time": null,
                        "urlSetting": '',
                    };
                } else {
                    __CacheData__ = data;
                };
                $('#readMessage').text('连接数据库...');
                proxy.getDBObject(__DBConfig__, function (data) {
                    __DBObject__ = data;
                    renderFiles();
                });
            });
        });
    };
});
